<template>
<el-row>
    <el-col :span="6">
        <el-statistic title="当天营收" :value="dayIncome" />
    </el-col>
    <el-col :span="6">
        <el-statistic title="当天营收(含未入账)" :value="dayIncomeAll" />
    </el-col>
    <el-col :span="6">
        <el-statistic title="本月营收" :value="monthIncome" />
    </el-col>
    <el-col :span="6">
        <el-statistic title="本年营收" :value="outputValue" />
    </el-col>
</el-row>
</template>

<script setup>
import { ref,onBeforeMount,getCurrentInstance } from 'vue'
import { useTransition } from '@vueuse/core'
import { useStore } from '@/stores'

const { proxy } = getCurrentInstance()
const store = useStore()

const dayIncome = ref(0)
const dayIncomeAll = ref(0)
const yearIncome = ref(0)
const monthIncome = ref(0)
const outputValue = useTransition(yearIncome, {
    duration: 1500,
})


onBeforeMount(async ()=>{
    let { data: res} = await proxy.$http({
		  method:'get',
          headers: {
		    'Authorization': store.token	//	可以是授权凭证用的参数值
	      },
		  url:'/api/admin/statics'
	})
    dayIncome.value=res.data.dayIncome
    dayIncomeAll.value=res.data.dayIncomeAll
    monthIncome.value=res.data.monthIncome
    yearIncome.value=res.data.yearIncome
})
</script>

<style scoped>
.el-col {
    text-align: center;
}
</style>
